package ThematicModelProto;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.util.ArrayList;

import org.w3c.dom.Document;
import org.xml.sax.SAXException;

import com.aetrion.flickr.FlickrException;



public class tester{
	
	public static void main(String args[]) throws IOException, SAXException, FlickrException{
	
		Document document = FlickrFabulaBuilder.generateFabula("London", 30000);
		String fabulaFile = "/home/pm5/workspace/Thematic Model Test/fabula/london-30000.fab";
		
		File f = new File(fabulaFile);
		
		try {
	        BufferedWriter out = new BufferedWriter(new FileWriter(f));
	        out.write(Helpers.xmlToString(document));
	        out.close();
	    } catch (IOException e) {
	    	e.printStackTrace();
	    }
		
		ArrayList<String> themes = new ArrayList<String>();
		themes.add("winter");
		ThematicModelBuilder tmb = new ThematicModelBuilder(themes,"/home/pm5/workspace/Thematic Model Test/themes/");
		tmb.loadFabula(fabulaFile);
		ArrayList<Natom> natoms = tmb.getStorySelection();
		
		System.out.println(tmb.selectionToBriefList(natoms, 30));
		
		
		
		//ThematicModelBuilder tmb = new ThematicModelBuilder(themes,"D:\\PhD\\Thematics\\implementation\\models2\\");
		
		
		
				//ArrayList<Theme> themeList = new ArrayList<Theme>();
				//themeList.add(tmb.themes.get("celebration"));
				//themeList.add(tmb.themes.get("family"));
				
				//tmb.generateFabula("zoo", 25000);
				//tmb.generateFabula("london", 30000);
				//tmb.generateFabula("new house", 30000);
				//tmb.generateFabula("funeral", 30000);
				//tmb.generateFabula("london", 10000);
				//tmb.generateFabula("new york", 10000);
				
				//tmb.loadFabula("D:\\PhD\\Thematics\\implementation\\fabula\\newyork5000.fab");
				
	//for(int i = 0; i<nList.size(); i++){
		//System.out.println("URL: "+nList.get(i).url+" "+nList.get(i).thematicScore+" "+nList.get(i).motifsmatch);
		//System.out.println("CC: "+nList.get(i).componentScore);
		//System.out.println("CF: "+tmb.calculateComponentFocus(themeList.get(0), nList.get(i)));
		//System.out.println("CM: "+tmb.calculateComponentMatch(themeList.get(0), nList.get(i)));
		
	//}
				

		
		/*ArrayList<String> ttl = new ArrayList();
		ttl.add("band");
		ttl.add("wedding dress");
		ttl.add("fireworks");
		Natom tt = new Natom("1","jhg", ttl);
		System.out.println("TEST: "+tmb.calculateComponentCoverage(themeList, tt));
		System.out.println("CF: "+tmb.calculateComponentFocus(themeList.get(0), tt));
		System.out.println("CM: "+tmb.calculateComponentMatch(themeList.get(0), tt));
		*/
		///////////
		
		//ArrayList<Natom> nList = tmb.getStorySelection("tragedy", 25000,themeList, 10);
		
		/////////////
		
		/*tmb.writeSelectionRecord("TMB1", "london", 30000, themeList, 10);
		tmb.natoms.clear();
		themeList = new ArrayList();
		themeList.add(tmb.themes.get("celebration"));
		tmb.writeSelectionRecord("TMB2", "earthquake", 30000, themeList, 10);
		tmb.natoms.clear();
		themeList = new ArrayList();
		themeList.add(tmb.themes.get("spring"));
		tmb.writeSelectionRecord("TMB3", "picnic", 30000, themeList, 10);
		tmb.natoms.clear();
		themeList = new ArrayList();
		themeList.add(tmb.themes.get("family"));
		tmb.writeSelectionRecord("TMB4", "factory", 30000, themeList, 10);
		tmb.natoms.clear();
		themeList = new ArrayList();
		themeList.add(tmb.themes.get("family"));
		themeList.add(tmb.themes.get("winter"));
		tmb.writeSelectionRecord("TMB5", "new york", 30000, themeList, 10);
		tmb.natoms.clear();
		themeList = new ArrayList();
		themeList.add(tmb.themes.get("spring"));
		themeList.add(tmb.themes.get("celebration"));
		tmb.writeSelectionRecord("TMB6", "new house", 30000, themeList, 10);
		tmb.natoms.clear();
		*/
	
		/*
		tmb.generateFabula("london", 30000);
		tmb.natoms.clear();
		tmb.generateFabula("new york", 30000);
		tmb.natoms.clear();
		tmb.generateFabula("Hospital", 30000);
		tmb.natoms.clear();
		tmb.generateFabula("Earthquake", 30000);
		tmb.natoms.clear();
		tmb.generateFabula("Bankruptsy", 30000);
		tmb.natoms.clear();
		tmb.generateFabula("Flood", 30000);
		tmb.natoms.clear();
		tmb.generateFabula("factory", 30000);
		tmb.natoms.clear();
		tmb.generateFabula("picnic", 30000);*/
		
		//tmb.natoms.clear();
		//tmb.generateFabula("new house", 30000);
		
	}
	
}